﻿#pragma once


#include "Widgets/Widget.h"
#include "RootWidget.m.h"

class RWindow;
class CRenderSurface;

RCLASS()
class WHENGINE_API RRootWidget : public RWidget
{
    ROBJECT


public:
    virtual RApplication* GetApplication() override; 

    void SetApplication(RApplication* InApplication);

    virtual void CalculatePresentPositionAndSize() override;

    TOptional<SRect> GetPaintArea() override;
    TOptional<SRect> GetSubWidgetPaintArea() override;

    //是否填充
    //如果不填充，窗口背景可能是透明的也可能是白色的，目前出现白色的条件尚不确定
    RFIELD()
    TWidgetAttribute<bool> Fill=true;

    //填充颜色
    RFIELD()
    TWidgetAttribute<SColor> FillColor=SColor(1,1,1,1);
    
    virtual void PaintSelf(uint16_t&  InZOrder,const SRect& InClipArea) override;

    //void SetRenderSurface(TThreadSafeSharedPtr<CRenderSurface> InRenderSurface);
protected:
    RApplication* Application=nullptr;

    TSharedObjectPtr<RWindow> GetWindow();

    //TThreadSafeSharedPtr<CRenderSurface> RenderSurface;
};